import numpy as np
import matplotlib.pyplot as plt

N = 100
def sp1(x):
    return 6.67 + 1.77167*(x) + 0.457833*(x)*(x-6) - 0.124778*(x)*(x-6)*(x-10) + 0.013566*(x)*(x-6)*(x-10)*(x-13) - 0.000978085*(x)*(x-6)*(x-10)*(x-13)*(x-17) + 4.1477e-05*(x)*(x-6)*(x-10)*(x-13)*(x-17)*(x-20)

def sp2(x):
    return 6.67 + 1.57167*(x) - 0.0871667*(x)*(x-6) - 0.0152729*(x)*(x-6)*(x-10) + 0.00257908*(x)*(x-6)*(x-10)*(x-13) - 0.000204804*(x)*(x-6)*(x-10)*(x-13)*(x-17) + 8.6768e-06*(x)*(x-6)*(x-10)*(x-13)*(x-17)*(x-20)

plt.figure(1)
x = np.linspace(0, 28, N)
plt.title("Average weight curve for each sample")
plt.xlabel("Days")
plt.ylabel("Weight")

l = np.zeros(N)
plt.plot(x, sp1(x), label = 'Sp1')
plt.plot(x, sp2(x), label = 'Sp2')
plt.plot(x, l, '--')


plt.legend()
plt.savefig("E_a.png", dpi = 750, bbox_inches = 'tight')


#  43days
plt.figure(2)
x = np.linspace(0, 43, N)
plt.title("Average weight curve for each sample")
plt.xlabel("Days")
plt.ylabel("Weight")

l = np.zeros(N)
plt.plot(x, sp1(x), label = 'Sp1')
plt.plot(x, sp2(x), label = 'Sp2')
plt.plot(x, l, '--')
plt.axvline(x=43, color='red', label = 'days = 43')


plt.legend()
plt.savefig("E_b.png", dpi = 750, bbox_inches = 'tight')
